home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Run Magazine ReRun: Productivity Pak 2
/
rerun-productivity-pak-ii.d64
/
logo for kids
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
12KB
|
446 lines
10 rem 'elmer the turtle'
20 rem (logo for kids)
30 :
40 rem version l-14
50 :
60 rem use on commodore 64
70 :
80 :
90 rem arrays
100 :
110 dim b(12)
120 dim a$(36),b$(36),c$(12)
130 :
140 rem variables
150 :
160 b=0
170 read b$:if b$="e" then bl=b:goto 200
180 b=b+1:b$(b)=b$:b(b)=len(b$)
190 read c(b):goto 170
200 s$=" "
210 er$="[145]"+s$+s$+s$+"[145]"
220 al=36:d=54272:u=10
230 t$="[158]* * * * * * *"
240 poke 53280,3:poke 53281,3:poke 646,6
250 :
260 rem title page
270 :
280 poke 53280,3:poke 53281,3:poke 646,6
290 print "[147]",t$
300 print "[144] elmer the turtle"
310 print ,t$
320 print "this game lets you draw and write on "
330 print " this computer screen."
340 print "just like other games, there are some"
350 print " rules for playing this game."
360 print "press the space bar if you want"
370 print " to read the rules."
380 print "or press the return key if you know"
390 print " them already and want to start"
400 print " playing right away."
410 a$=""
420 get a$:if a$="" then 420
430 if asc(a$)=13 then 530
440 if asc(a$)<>32 then 420
450 :
460 rem display all instructions
470 :
480 gosub 2910:gosub 3040:gosub 3170
490 gosub 3290:gosub 3400:gosub 3560
500 gosub 3650:gosub 3770:gosub 3920
510 gosub 4310
520 :
530 rem continue directions?
540 :
550 print "[147]",t$
560 print "everyone sometimes makes mistakes"
570 print " when they play this game."
580 print "the computer can often help you find"
590 print " out what you did wrong and show you"
600 print " the rule for that part."
610 print "please press the space bar if you want"
620 print " the computer to help find mistakes,"
630 print "or press the return key if you do not."
640 print ,t$
650 q=0:a$=""
660 get a$:if a$="" then 660
670 if asc(a$)=13 then u=0:goto 700
680 if asc(a$)<>32 then 660
690 u=1
700 :
710 :
720 rem statement list display
730 :
740 print "[147]";:n=18:for o=1 to 18
750 print "";right$(str$(o),2);". ";
760 print "";a$(o);tab(20);
770 print "";right$(str$(o+n),2);". ";
780 print "";a$(o+n):next o:print
790 if q=1 then 980
800 :
810 rem line # input
820 :
830 input "line #, 'e' or 'new'";i$
840 print er$:if i$="e" then 1610
850 if i$<>"new" then 870
860 for a=1 to 36:a$(a)="":next:goto710
870 i=len(i$):if i<1 or i>3 then 940
880 if i$="0" then 940
890 n=asc(i$):if n<49 or n>57 then 940
900 n=asc(right$(i$,1))
910 if n<49 and n>57 then 940
920 a=val(i$)
930 if a>0 and a=<al then 980
940 gosub 2500:if u=0 then 810
950 print "[147]"
960 gosub 3040:gosub 4090:goto 710
970 :
980 rem statement display
990 :
1000 q=1:print "[145]";
1010 for m=1 to 3:for n=0 to 3
1020 b=m+n*3:if b>bl then 1040
1030 print tab(n*10);b$(b);
1040 next n:print:next m
1050 print "i[158]nsert d[158]elete ";
1060 print "b[158]ack to line #"
1070 :
1080 rem statement input
1090 :
1100 print "line";a;:i$="":input i$
1110 print er$:if i$="" then gosub 2500:goto 1070
1120 if i$="i" then 1540
1130 if i$="d" then 1580
1140 if i$="b" then q=0:goto 710
1150 :
1160 rem is 'i$' valid?
1170 :
1180 b=0:i=len(i$)
1190 b=b+1:if b>bl then gosub 2500:goto 1070
1200 if left$(i$,b(b))<>b$(b) then 1190
1210 rem ....stmt #c
1220 c=c(b):if c>0 then 1260
1230 rem ....stmt type 0
1240 if i$=b$(b) then a$(a)=i$:q=0:goto 710
1250 goto 1370
1260 m$=right$(i$,i-b(b))
1270 gosub 2590
1280 j$=m$:j=len(j$):if c>1 then 1420
1290 rem ....stmt type 1
1300 if j=0 or j>2 then 1370
1310 n=asc(left$(j$,1))
1320 if n<48 or n>57 then 1370
1330 n=asc(right$(j$,1))
1340 if n<48 or n>57 then 1370
1350 n=val(j$):if b=8 and n<16 then 1460
1360 if b<>8 and n>0 then 1460
1370 gosub 2500:if u=0 then 1070
1380 print "[147]":if b>4 then 1400
1390 gosub 3190:goto 710
1400 on b-4 gosub 3290,3290,3400,3560,3650,3770
1410 goto 710
1420 if c>2 then 1480
1430 rem ....stmt type 2
1440 if j<>1 then 1370
1450 n=asc(j$):if n<33 or n>95 then 1400
1460 rem ....i$ is valid statement
1470 a$(a)=b$(b)+" "+j$:q=0:goto 710
1480 if c>3 then 1370
1490 rem ....stmt type 3
1500 if mid$(i$,5,1)=" " then 1520
1510 i$=left$(i$,4)+" "+mid$(i$,5)
1520 n=len(i$):if n<6 or n>15 then 1370
1530 a$(a)=i$:q=0:goto 710
1540 rem ....insert blank line
1550 for m=35 to a step -1
1560 a$(m+1)=a$(m):next m
1570 a$(a)="":q=0:goto 710
1580 rem ....delete line
1590 if a=36 then 1600
1595 for m=a to 35:a$(m)=a$(m+1):next
1600 a$(36)="":q=0:goto 710
1610 :
1620 rem begin execution
1630 :
1640 x=1:y=1:rem initial position
1650 e=2:rem initial pen position
1660 h$="*":rem initial character
1670 l=6:rem initial color #
1680 poke 53280,5:rem border color
1690 print "[147]":gosub 2770:gosub 2710
1700 rem ....statement list
1710 for a=1 to al:a$=a$(a)
1720 if a$="" then 2330
1730 b=0
1740 b=b+1
1750 if left$(a$,b(b))<>b$(b) then 1740
1760 on b goto 1780,1850,1920,1990,2060,2100,2130,2170,2210,2290
1770 :
1780 rem ....right
1790 m$=right$(a$,len(a$)-b(b))
1800 gosub 2590:m=val(m$)
1810 for n=1 to m:gosub 2370
1820 x=x+1:if x=41 then x=1
1830 gosub 2710:next n:goto 2330
1840 :
1850 rem ....up
1860 m$=right$(a$,len(a$)-b(b))
1870 gosub 2590:m=val(m$)
1880 for n=1 to m:gosub 2370
1890 y=y-1:if y=0 then y=25
1900 gosub 2710:next n:goto 2330
1910 :
1920 rem ....down
1930 m$=right$(a$,len(a$)-b(b))
1940 gosub 2590:m=val(m$)
1950 for n=1 to m:gosub 2370
1960 y=y+1:if y=26 then y=1
1970 gosub 2710:next n:goto 2330
1980 :
1990 rem ....left
2000 m$=right$(a$,len(a$)-b(b))
2010 gosub 2590:m=val(m$)
2020 for n=1 to m:gosub 2370
2030 x=x-1:if x=0 then x=40
2040 gosub 2710:next n:goto 2330
2050 :
2060 rem ....pen up
2070 if e=0 then e=1
2080 goto 2330
2090 :
2100 rem ....pen down
2110 e=0:goto 2330
2120 :
2130 rem ....char
2140 h$=right$(a$,1):gosub 2770
2150 p=983+x+y*40:poke p,k
2152 gosub 2750:goto 2330
2160 :
2170 rem ....color
2180 l=val(mid$(a$,6)):p=983+x+y*40
2190 poke p+d,l:gosub 2750:goto 2330
2200 :
2210 rem ....text
2220 a$=mid$(a$,6):m=len(a$)
2225 x=x-1:if x=0 then x=40
2230 gosub 2370:j=k:for n=1 to m
2240 h$=mid$(a$,n,1):gosub 2770
2250 x=x+1:if x=41 then x=1
2260 gosub 2710:next n
2270 k=j:f=1:m=1:goto 1810
2280 :
2290 rem ....stop
2300 a$=""
2310 get a$:if a$="" then 2310
2320 goto 2330
2330 next a:q=0:goto 710
2340 :
2350 rem subroutines
2360 :
2370 rem ....erase previous point?
2380 if f=1 then f=0:return
2390 if e=1 then e=2:return
2400 if e=2 then poke p+d,v:poke p,w
2410 return
2420 :
2430 rem ....instruction input
2440 print ""
2450 print " press any key to ";
2460 print "continue":a$=""
2470 get a$:if a$="" then 2470
2480 print "[147]":return
2490 :
2500 rem ....error message
2510 print ,"[144]i don't understand that"
2520 gosub 2560:print er$
2530 print ,"please try again"
2540 gosub 2560:print er$:return
2550 :
2560 rem ....screen message delay
2570 for t=1 to 500:next t:return
2580 :
2590 rem ....truncate m$
2600 if m$="" then return
2610 m=asc(left$(m$,1))
2620 if m=32 then 2640
2630 if m<>160 then 2650
2640 m$=right$(m$,len(m$)-1):goto 2610
2650 if m$="" then return
2660 m=asc(right$(m$,1))
2670 if m=32 then 2690
2680 if m<>160 then return
2690 m$=left$(m$,len(m$)-1):goto 2650
2700 :
2710 rem ....poke screen character
2720 p=983+x+y*40
2730 v=peek(p+d):w=peek(p)
2740 poke p+d,l:poke p,k
2750 for t=1 to 50:next t:return
2760 :
2770 rem ....calc screen display value
2780 h=asc(h$):if h<64 then k=h:return
2790 k=h-64:return
2800 :
2810 rem fixed data
2820 :
2830 data right,1,up,1,down,1,left,1
2840 data pen up,0,pen down,0,char,2
2850 data color,1,text,3,stop,0
2860 data e
2870 :
2880 :
2890 rem title/instructions
2900 :
2910 print "[147][144] how to play with elmer"
2920 print "this program provides you with a"
2930 print " tiny, make-believe turtle named elmer"
2940 print " who walks around the screen."
2950 print "elmer carries a pen so that he "
2960 print " can write on the screen as he walks."
2970 print "you can tell elmer what to do by"
2980 print " giving him a list of instructions."
2990 print "each instruction has its own number"
3000 print " and you can have up to 36
3010 [153] " instructions on the list."
3020 [141] 2430:[142]
3030 :
3040 [1